#ifndef MAIN_WINDOW_H
#define MAIN_WINDOW_H

#include <gtkmm.h>
#include <atomic>
#include <functional>
#include <array>
#include <gtkmm/alertdialog.h>
#include "../include/ProjectClient.hpp"
#include "WebsocketClient.hpp"
#include "ServerControl.hpp"
#include "CreateProjectDialog.hpp"
#include "CreateTaskDialog.hpp"

class MainWindow : public Gtk::Window
{
  public:
    MainWindow();
    virtual ~MainWindow();
  private:
    class ModelColumns : public Gtk::TreeModel::ColumnRecord
    {
      public:
        ModelColumns() {add(m_col_name);add(m_col_info);add(col_level);}
        Gtk::TreeModelColumn<Glib::ustring> m_col_info;
        Gtk::TreeModelColumn<Glib::ustring> m_col_name;
        Gtk::TreeModelColumn<int> col_level;
    };
    ModelColumns m_columns;
    // Child widgets:
    Gtk::Box m_VBox;
    Gtk::ScrolledWindow m_ScrolledWindow;
    Gtk::Grid m_ButtonGrid;
    Gtk::Button btnCreateProject;
    Gtk::Button btnCreateTask;
    Gtk::Button btnShotControl;
    Gtk::TreeView projectView;

    Glib::RefPtr<Gtk::TreeStore> m_refTreeModel;

    std::unique_ptr<ProjectClient> projectClient;
    std::unique_ptr<ServerControl> serverControl;
    std::unique_ptr<WebsocketClinet> wsClient;
    Glib::RefPtr<Gtk::AlertDialog> dlgMsg;
    CreateProjectDialog createProjectDlg;
    CreateTaskDialog createTaskDlg;
    void on_createProjectDlg_hidden();
    void on_createTaskDlg_hidden();

    void on_btnCreateProject_click();
    void on_btnCreateTask_click();
    void on_btnShotControl();
    void on_btnOpenRealtime_click();
    
    
    void on_projectView_row_activated(const Gtk::TreeModel::Path& path,Gtk::TreeViewColumn* column);
    void UpdateProjectView();
};

#endif
